package com.cs307.redcross.client;

import java.io.Serializable;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.ToggleButton;

public class DeveloperHeader extends Composite implements Serializable {
	private static final long serialVersionUID = 6894468356507740802L;
	protected ToggleButton selectedButton;
	
	public DeveloperHeader() {
		
		HorizontalPanel horizontalPanel = new HorizontalPanel();
		horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		initWidget(horizontalPanel);
		horizontalPanel.setSize("128px", "14px");
		
		ToggleButton errorLogsButton = new ToggleButton("Error Logs");
		errorLogsButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				
				// set the contentPanel to display the content needed
				ContentPanel.getInstance().setContent(new ErrorLogsContent());
				
				// clear the subheader
				SubheaderPanel.getInstance().clearSubheader();
				
				// untoggle the last selected button
				if (selectedButton != null)
					selectedButton.setDown(false);
				selectedButton = (ToggleButton)event.getSource();
			}
		});
		horizontalPanel.add(errorLogsButton);
		errorLogsButton.setWidth("99px");
	}
	
}
